diff --git a/django/core/management/commands/makemigrations.py b/django/core/management/commands/makemigrations.py
index 0b39536f5b..b7cf7abd54 100644
--- a/django/core/management/commands/makemigrations.py
+++ b/django/core/management/commands/makemigrations.py
@@ -101,13 +101,11 @@ class Command(BaseCommand):
         aliases_to_check = connections if settings.DATABASE_ROUTERS else [DEFAULT_DB_ALIAS]
         for alias in sorted(aliases_to_check):
             connection = connections[alias]
-            if (connection.settings_dict['ENGINE'] != 'django.db.backends.dummy' and any(
-                    # At least one model must be migrated to the database.
-                    router.allow_migrate(connection.alias, app_label, model_name=model._meta.object_name)
-                    for app_label in consistency_check_labels
-                    for model in apps.get_models(app_label)
-            )):
-                loader.check_consistent_history(connection)
+            if connection.settings_dict['ENGINE'] != 'django.db.backends.dummy':
+                for app_label in consistency_check_labels:
+                    app_models = apps.get_models(app_label)
+                    if any(router.allow_migrate(connection.alias, app_label, model_name=model._meta.object_name) for model in app_models):
+                        loader.check_consistent_history(connection)
 
         # Before anything else, see if there's conflicting apps and drop out
         # hard if there are any and they don't want to merge
